package xiaodou.data.account
{
	import xiaodou.core.ObjectUtil;
	import xiaodou.data.blogAccount.BlogAccountData;
	

	public class UserData
	{
		/**
		 * 标识 
		 */		
		public var id:int;
		
		/**
		 * 帐号 
		 */		
		public var name:String;
		
		/**
		 * 密码 
		 */		
		public var password:String;
		
		/**
		 * 权限 
		 */		
		public var access:int;
		
		/**
		 * 可操作的微博帐号 
		 */		
		public var blogAccountList:Array;
		
		public function UserData(name:String = null, password:String = null, access:int = 0)
		{
			this.name = name;
			this.password = password;
			this.access = access;
		}
		
		/**
		 * 是否有操作某微博帐号 
		 * @param blogAccountId 微博帐号
		 * @return 
		 * 
		 */		
		public function hasBlog(blogAccountId:int):Boolean
		{
			for each (var account:BlogAccountData in blogAccountList) 
			{
				if(account.id == blogAccountId)
					return true;
			}
			return false;
		}
		
		public function fill(data:Object):void
		{
			ObjectUtil.fill(data, this);
			if(data.blogAccountList)
			{
				blogAccountList = new Array();
				for (var i:int = 0; i < data.blogAccountList.length; i++) 
				{
					var blogAccount:BlogAccountData = new BlogAccountData();
					blogAccount.fill(data.blogAccountList[i]);
					blogAccountList.push(blogAccount);
				}
				
			}
		}
	}
}